package com.hqyj.first.service.impl;

import com.hqyj.first.domain.Users;
import com.hqyj.first.repository.UsersRepository;
import com.hqyj.first.service.UsersService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;

@Service
public class UsersServiceImpl implements UsersService {

    @Resource
    private UsersRepository usersRepository;

    @Override
    public Users queryUserByUid(Integer uid) {
        Optional<Users> optional = usersRepository.findById(uid);
        return optional.orElse(null);
    }

    @Override
    public Users saveUser(Users u) throws Exception {
        return usersRepository.save(u);
    }
}
